package com.lzx.guanchajava.pojo.bean.newsList

import android.view.View
import com.lzx.guanchajava.pojo.TAG
import com.lzx.guanchajava.pojo.bean.BaseNewsItem
import com.lzx.guanchajava.util.ActivityStatic
import com.lzx.guanchajava.util.App
import com.lzx.guanchajava.util.ImageUtils
import com.lzx.guanchajava.util.JumpUtil
import com.lzx.guanchajava.view.activity.MainActivity
import com.lzx.guanchajava.view.activity.NewsActivity
import com.lzx.guanchajava.view.activity.PostActivity
import com.lzx.guanchajava.view.activity.TagsActivity

data class News(
        val author: Author,
        val comment_num: Int,
        val id: String,
        val news_time: String,
        val news_type: Int,
        val pic: String,
        val show_type: Int,
        val summary: String,
        val special: Special?,
        val title: String,
        val url: String,
        val user: User
) : BaseNewsItem() {
    fun onNewsTagClick(id: String?) {
        //toTagsAct(id)
        id?.let {
            JumpUtil.startActivity(ActivityStatic.getInstance().activity, TagsActivity::class.java, TAG.ACTIVITY_TAGS to it)
        }
    }

    fun onNewsLongClick(imageUrl: String, ancherView: View) {
        ImageUtils.saveImageWithPopup(imageUrl, ancherView)
    }

    fun onNewsClick(id: String, type: String) {
        if (type == "1") JumpUtil.startActivity(ActivityStatic.getInstance().activity, NewsActivity::class.java, "ID" to id, "CODETYPE" to type)
        else JumpUtil.startActivity(ActivityStatic.getInstance().activity, PostActivity::class.java, "ID" to id, "CODETYPE" to type)
    }
}